#include<bits/stdc++.h>
using namespace std;
class Solution {
public:
    vector<int> test(string s)
    {
        int count1=0;
        int count2=0;
        for(char ch:s)
        if(ch=='1') count1++;
        else count2++;

        return {count2,count1};
    }
    int findMaxForm(vector<string>& strs, int m, int n) {
        int l=strs.size();
        vector<vector<vector<int>>> dp(l+1,vector<vector<int>>(m+1,vector<int>(n+1)));
        vector<vector<int>> vec;
        for(auto it:strs)
            vec.push_back(test(it));
        for(int i=1;i<=l;i++)
        {
            for(int j=0;j<=m;j++)
            {
                for(int k=0;k<=n;k++)
                {
                    dp[i][j][k]=dp[i-1][j][k];
                    if(j>=vec[i-1][0]&&k>=vec[i-1][1])
                        dp[i][j][k]=max(dp[i][j][k],dp[i-1][j-vec[i-1][0]][k-vec[i-1][1]]+1);
                }
            }
        }
        return dp[l][m][n];
    }
};